package com.ruibang.glass.produce.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.produce.entity.MaterialItemInfo;
import com.ruibang.glass.produce.mapper.MaterialItemInfoMapper;
import com.ruibang.glass.produce.service.MaterialItemInfoService;
import io.seata.common.util.CollectionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-03-19  09:14
 * @Description: TODO
 * @Version: 1.0
 */

@Slf4j
@Service
public class MaterialItemInfoServiceImpl extends ServiceImpl<MaterialItemInfoMapper, MaterialItemInfo> implements MaterialItemInfoService {


    @Override
    public List<MaterialItemInfo> getByMaterialReceiveLIds(List<String> ids) {
        if (CollectionUtils.isNotEmpty(ids)) {
            QueryWrapper<MaterialItemInfo> qw = new QueryWrapper<>();
            qw.lambda().in(MaterialItemInfo::getMaterialReceiveId, ids);
            return this.list(qw);
        }
        return Collections.emptyList();
    }

    @Override
    public List<MaterialItemInfo> getByMaterialReceiveId(String id) {
        return lambdaQuery().eq(MaterialItemInfo::getMaterialReceiveId, id).list();
    }

    @Override
    public void deleteByMaterialReceiveId(String materialReceiveId) {
        QueryWrapper<MaterialItemInfo> qw = new QueryWrapper<>();
        qw.lambda().eq(MaterialItemInfo::getMaterialReceiveId, materialReceiveId);
        this.remove(qw);
    }
}
